package main;

import java.util.Vector;

import entities.FragmentDirectory;
import entities.MMMEDirectory;
import fragment.Behavior;
import fragment.ContactHandler;
import fragment.ExternalViewer;
import fragment.Fragment;
import fragment.Generation;
import fragment.LifeCycle;
import fragment.MessageHandler;
import fragment.ProcessHandler;
import fragment.Reservation;
import fragment.Stimulation;

public class FragmentFactory {
		
	public static Fragment create( 	String id, 
									Vector<String> generationCapabilities, 
									Vector<String> requiredElements,
									int preference,
									FragmentDirectory fragDir,
									MMMEDirectory elemDir
								  ) 
		{
		
		Stimulation stimTemp=new Stimulation(preference);					//Needed by current MAY implementation
		ContactHandler contTemp=new ContactHandler(elemDir,fragDir);	//Needed by current MAY implementation
		
		Fragment agent = new Fragment(	new MessageHandler(),
										new LifeCycle(),
										new Generation(generationCapabilities),
										new Reservation(requiredElements),
										stimTemp,
										new ProcessHandler(),
										contTemp,
										new ExternalViewer(id),
										new Behavior()
									  );
		
		stimTemp.linkReference(agent);		//Needed by current MAY implementation
		contTemp.linkReference(agent);		//Needed by current MAY implementation
		
		//agent.start();
		return agent;
		}
}
